package com.xinwei.leetcode.二叉树;


import java.util.LinkedList;

// https://leetcode-cn.com/problems/range-sum-of-bst/
public class _938_二叉搜索树的范围和 {
    int sum = 0;
    // 中序遍历
    public int rangeSumBST(TreeNode root, int low, int high) {
        if (root == null) return sum;
        rangeSumBST(root.left, low, high);
        if (root.val >= low && root.val <= high) {
            return sum += root.val;
        }
        rangeSumBST(root.right, low, high);
        return sum;

    }
}
